package ai.xiaodao.config;

import ai.xiaodao.tool.ConfigUtil;
import org.apache.log4j.Logger;

import java.util.Properties;

import static java.lang.System.exit;

/**
 * init database config
 */

public class DBConfig {
    static Logger log = Logger.getLogger(DBConfig.class.getName());
    private static Properties prop = new Properties();

    public  static void getIns(String conf) {
        //check the input config file path
        if (null != conf && conf.length() > 0) {
            prop = ConfigUtil.readProps(conf);
        } else {
            log.error("The config path in correct please check");
            exit(0);
        }
    }

    public static String getProp(String key) {
        return prop.getProperty(key);
    }

    public static Properties getProps() {
        return prop;
    }

    public static   String getDBName() {
        return prop.getProperty(Const.DB_NAME);
    }

    public static String getDBScriptPath() {
        return prop.getProperty(Const.DB_SCRIPT);

    }

    public static String getDataDir() {
        return prop.getProperty(Const.DB_DATADIR);

    }
}
